import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/register', component: () => import('@/views/login/register'), hidden: true },
  { path: '/changePassword', component: () => import('@/views/systemSetting/changePassword'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'dashboard',
    meta: { title: '首页' },
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'table' }
    }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/basicSetting',
    component: Layout,
    redirect: '/basicSetting/examinationRoom',
    name: 'BasicSetting',
    meta: { title: '基础数据设置', icon: 'setting', roles: ['admin', 'activePublisher'] },
    children: [
      {
        path: 'examinationRoom',
        name: 'examinationRoom',
        component: () => import('@/views/basicInfoSetting/examinationRoomResourceSetting'),
        meta: { title: '教室资源设置', icon: 'building', roles: ['admin', 'activePublisher'] }
      },
      {
        path: 'teacher',
        name: 'teacherList',
        component: () => import('@/views/basicInfoSetting/teacherSetting'),
        meta: { title: '考务人员设置', icon: 'user', roles: ['admin', 'activePublisher'] }
      },
      {
        path: 'examinationRules',
        name: 'examinationRulesSetting',
        component: () => import('@/views/basicInfoSetting/createArticle'),
        meta: { title: '考务规定设置', icon: 'rule', roles: ['admin'] }
      }
    ]
  },
  {
    path: '/form',
    redirect: '/form/queryActivity',
    component: Layout,
    name: 'form',
    meta: { title: '监考活动管理', icon: 'activeManage', roles: ['admin', 'activePublisher', 'examinationStaff'] },
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: '发布监考活动', icon: 'publish', roles: ['admin', 'activePublisher'] }
      },
      {
        path: 'myExaminationActive',
        name: 'myExaminationActive',
        component: () => import('@/views/form/myExaminationActive'),
        meta: { title: '我发布的活动', icon: 'myActive', roles: ['admin', 'activePublisher'] }
      },
      {
        path: 'queryActivity',
        name: 'queryActivity',
        component: () => import('@/views/form/queryActivity'),
        meta: { title: '查询监考活动', icon: 'query' }
      },
      {
        path: 'mySignupActivity',
        name: 'mySignupActivity',
        component: () => import('@/views/form/mySignupActivity'),
        meta: { title: '我的报名', icon: 'signup', roles: ['examinationStaff', 'activePublisher'] }
      }
    ]
  },
  {
    path: '/trainManagement',
    redirect: '/trainManagement/settingTrainTime',
    component: Layout,
    name: 'trainManagement',
    meta: { title: '监考培训管理', icon: 'examArrange', roles: ['admin', 'activePublisher'] },
    children: [
      {
        path: 'settingTrainTime',
        name: 'settingTrainTime',
        component: () => import('@/views/trainManagement/settingTrainTime'),
        meta: { title: '设置培训时间', icon: 'timeSetting', roles: ['admin', 'activePublisher'] }
      },
      {
        path: 'trainResultImport',
        name: 'trainResultImport',
        component: () => import('@/views/trainManagement/trainResultImport'),
        meta: { title: '导入考试成绩', icon: 'import', roles: ['admin', 'activePublisher'] }
      }
    ]
  },
  {
    path: '/examinationArrangement',
    redirect: '/examinationArrangement/invigilatorArrangement',
    component: Layout,
    name: 'examinationArrangement',
    meta: { title: '排考管理', icon: 'examArrange', roles: ['admin', 'activePublisher'] },
    children: [
      {
        path: 'index',
        name: 'invigilatorArrangement',
        component: () => import('@/views/examinationArrangement/invigilatorArrangement'),
        meta: { title: '导入监考安排', icon: 'evaluate', roles: ['admin', 'activePublisher'] }
      },
      {
        path: 'examineeArrangement',
        name: 'examineeArrangement',
        component: () => import('@/views/examinationArrangement/examineeArrangement'),
        meta: { title: '导入考生排考', icon: 'query', roles: ['admin', 'activePublisher'] }
      }
    ]
  },
  {
    path: '/evaluateTeacher',
    redirect: '/evaluateTeacher/index',
    component: Layout,
    name: 'evaluateTeacher',
    meta: { title: '监考评价管理', icon: 'evaluate1', roles: ['admin', 'activePublisher'] },
    children: [
      {
        path: 'index',
        name: 'EvaluateTeacher',
        component: () => import('@/views/evaluateTeacher/index'),
        meta: { title: '评价监考教师', icon: 'evaluate', roles: ['admin', 'activePublisher'] }
      },
      {
        path: 'history',
        name: 'EvaluateTeacherHistory',
        component: () => import('@/views/evaluateTeacher/history'),
        meta: { title: '查询监考历史', icon: 'query', roles: ['admin', 'activePublisher'] }
      }
    ]
  },
  {
    path: '/invigilateRecords',
    redirect: '/invigilateRecords/index',
    component: Layout,
    name: 'invigilateRecords',
    meta: { title: '我的监考记录', icon: 'records', roles: ['activePublisher', 'examinationStaff'] },
    children: [
      {
        path: 'index',
        name: 'myInvigilateRecords',
        component: () => import('@/views/form/myInvigilateRecords'),
        meta: { title: '我的监考记录', icon: 'records', roles: ['activePublisher', 'examinationStaff'] }
      }
    ]
  },
  {
    path: '/myExamArrangement',
    redirect: '/myExamArrangement/index',
    component: Layout,
    name: 'myExamArrangement',
    meta: { title: '我的考试安排', icon: 'examArrangement', roles: ['examinee'] },
    children: [
      {
        path: 'index',
        name: 'myExamArrangement',
        component: () => import('@/views/examinationArrangement/myExamArrangement'),
        meta: { title: '我的考试安排', icon: 'examArrangement', roles: ['examinee'] }
      }
    ]
  },
  {
    path: '/systemSetting',
    component: Layout,
    redirect: '/userInfoCheck',
    name: 'systemSetting',
    meta: { title: '系统设置', icon: 'setting' },
    children: [
      { path: 'changePassword',
        component: () => import('@/views/systemSetting/changePassword'),
        meta: { title: '修改密码', icon: 'password', roles: ['activePublisher', 'examinationStaff', 'examinee'] }
      },
      { path: 'userInfoCheck',
        component: () => import('@/views/systemSetting/userInfoCheck'),
        meta: { title: '个人信息核对', icon: 'check', roles: ['activePublisher', 'examinationStaff'] }
      },
      { path: 'feedback',
        component: () => import('@/views/systemSetting/feedback'),
        meta: { title: '意见反馈', icon: 'feedback', roles: ['activePublisher', 'examinationStaff', 'examinee'] }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
